{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/filtered-dumping-academia.txt\n",
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/filtered-dumping-wiki.txt\n",
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/dumping-iium.txt\n",
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/dumping-news.txt\n",
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/dumping-parliament.txt\n",
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/true-case-stt.txt\n",
    "# !wget https://f000.backblazeb2.com/file/malay-dataset/dumping/clean/filtered-dumping-cleaned-common-crawl.txt\n",
    "# !wget https://huggingface.co/datasets/mesolitica/raw-text/resolve/main/ms-only-eng_Latn-zsm_Latn.txt\n",
    "# !wget https://huggingface.co/datasets/mesolitica/en-ms/resolve/main/en-ms-left.train\n",
    "# !wget https://huggingface.co/datasets/mesolitica/ms-en/resolve/main/ms-en-left.train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "files = [\n",
    "    'filtered-dumping-academia.txt',\n",
    "    'filtered-dumping-wiki.txt',\n",
    "    'dumping-iium.txt',\n",
    "    'dumping-news.txt',\n",
    "    'dumping-parliament.txt',\n",
    "    'true-case-stt.txt',\n",
    "    'filtered-dumping-cleaned-common-crawl.txt',\n",
    "    'ms-only-eng_Latn-zsm_Latn.txt',\n",
    "    'en-ms-left.train',\n",
    "    'ms-en-left.train',\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "filtered-dumping-academia.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "5502536it [00:01, 3012753.78it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "filtered-dumping-wiki.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2621310it [00:00, 3108281.84it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dumping-iium.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "1139838it [00:00, 2883325.19it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dumping-news.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "1897306it [00:00, 2504375.37it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dumping-parliament.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "347202it [00:00, 2484543.99it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "true-case-stt.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "1404051it [00:00, 3353096.60it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "filtered-dumping-cleaned-common-crawl.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "65082254it [00:18, 3532499.15it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ms-only-eng_Latn-zsm_Latn.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "56832366it [00:19, 2875544.18it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "en-ms-left.train\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "3699402it [00:01, 2197586.97it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ms-en-left.train\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "3252224it [00:01, 2576467.52it/s]\n"
     ]
    }
   ],
   "source": [
    "with open('combined-gpt2.txt', 'w') as fopen:\n",
    "    for f in files:\n",
    "        print(f)\n",
    "        with open(f) as fr:\n",
    "            for l in tqdm(fr):\n",
    "                if len(l):\n",
    "                    fopen.write(f'{l}\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1294200776 combined-gpt2.txt\r\n"
     ]
    }
   ],
   "source": [
    "!wc -w combined-gpt2.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
